/**
 * 
 */
$(function() {
	$(".js-submit").click(function() {
		var company = $(".js-company-name").val();
		var phone = $(".js-phone").val();

		if (company == "" || phone == "") {
			alert("公司名或手机号码不能为空");
		} else if (!(/^1[34578]\d{9}$/.test(phone))) {
			alert("手机格式不对");
		} else {
			$.ajax({
				type: "POST",
				url: "/ideaController/saveForService",
				data: JSON.stringify({"company_name":company,"phone_number":phone}),
				dataType:'json',
				contentType:'application/json;charset=UTF-8',
				success: function(data){
					if(data.code==500){
						alert("请重新登录啦~");
						return;
					}
					$(".js-company-name").val("");
					$(".js-phone").val("");
					alert("提交成功");
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert("提交失败了哦~请稍后再试");
                }
			});
		}
	})
})